<?php
namespace core\execute\method;

use core\Object;
class Method implements Object{

	public static $PROPERTY_OBJECT  	= "object";
	public static $PROPERTY_NAME  		= "name";
	public static $PROPERTY_PARAMETERS  = "parameters";
	public static $PROPERTY_IS_PUBLIC  	= "isPublic";

	private $object;
	private $name;
	private $parameters;
	private $isPublic;

	public static function createMethod(Object $object, $method_name, array $parameters, $isPublic){
		$class = new \ReflectionClass(new Method());
		$method = $class->newInstanceWithoutConstructor();

		$propertyObject 	= $class->getProperty(static::$PROPERTY_OBJECT);
		$propertyObject->setAccessible(true);
		$propertyObject->setValue($method, $object);

		$propertyName		= $class->getProperty(static::$PROPERTY_NAME);
		$propertyName->setAccessible(true);
		$propertyName->setValue($method, $method_name);

		$propertyParameters = $class->getProperty(static::$PROPERTY_PARAMETERS);
		$propertyParameters->setAccessible(true);
		$propertyParameters->setValue($method, $parameters);

		$propertyIsPublic 	= $class->getProperty(static::$PROPERTY_IS_PUBLIC);
		$propertyIsPublic->setAccessible(true);
		$propertyIsPublic->setValue($method, $isPublic);

		return $method;
	}

	public static function addMethods(Method $method, array $methods){
		array_push($methods, $method);
		return $methods;
	}
}